package org.wddsicmd.app;

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.lang.Object;
import java.util.Vector;

public class CustomTableModel extends DefaultTableModel {
	public CustomTableModel(Object[][] data, Object[] columnNames) {
		super(data, columnNames);
	}
	public boolean isCellEditable(int rowindex,int colindex){
		if (colindex==0) return false;   
		return true;                     
	}
	public void fireTableCellUpdated(int row, int column) {
		fireTableChanged(new TableModelEvent(this, row, row, column));
		if(mFireTableCellUpdatedListener != null){
			mFireTableCellUpdatedListener.onFireTableCellUpdated(row, column);
		}
	}			
	public void setValueAtNoFire(Object aValue, int row, int column) {
		Vector rowVector = (Vector)dataVector.elementAt(row);
		rowVector.setElementAt(aValue, column);
	}			
	public void setValueAtLine(Object[] aValue, int row) {
		Vector rowVector = convertToVector(aValue);
		dataVector.setElementAt(rowVector, row);
	}
	public Vector getValueAtLine(int row){
        	Vector rowVector = (Vector)dataVector.elementAt(row);
		return rowVector;
	}
	public interface FireTableCellUpdatedListener{
		void onFireTableCellUpdated(int row, int column);
	}			
	FireTableCellUpdatedListener mFireTableCellUpdatedListener;
	public void setFireTableCellUpdatedListener(FireTableCellUpdatedListener l){
		mFireTableCellUpdatedListener = l;
	}
}
